package com.rex.module.user.entity;

import javax.persistence.*;
import org.apache.commons.lang3.builder.*;
import java.math.BigDecimal;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * (实体类)
 * Author: Generator
 * Version: 1.0.0
 * Date: 2018/1/17 23:55
 * Gitee: https://gitee.com/rexfang/
 * Email: fangruitao.work@foxmail.com
 * Blog: https://www.cnblogs.com/rexfang/
 */
@Entity
@Table(name = "sys_user" )
public class SysUser {
	public static final String ID = "id";
	public static final String USER_NAME = "userName";
	public static final String SEX = "sex";
	public static final String AGE = "age";
	public static final String MOBILE_PHONE = "mobilePhone";
	public static final String ADDRESS = "address";
	public static final String LOGIN_ID = "loginId";
	public static final String PASSWORD = "password";
	public static final String SALT = "salt";
	public static final String VERSION = "version";

	/** ID - ID */
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "ID", unique = true, nullable = false, insertable = true, updatable = true, length = 19)
	private Long id;
	/** USER_NAME - 用户名 */
	@NotBlank(message = "用户名不能为空")
	@Length(max = 16, message = "用户名长度不能超过16个字符")
    @Column(name = "USER_NAME", unique = false, nullable = false, insertable = true, updatable = true, length = 16)
	private String userName;
	/** SEX - 性别 */
	@NotBlank(message = "性别不能为空")
	@Length(max = 8, message = "性别长度不能超过8个字符")
    @Column(name = "SEX", unique = false, nullable = false, insertable = true, updatable = true, length = 8)
	private String sex;
	/** AGE - 年龄 */
    @Column(name = "AGE", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	private Integer age;
	/** MOBILE_PHONE - 手机 */
	@Length(max = 16, message = "手机长度不能超过16个字符")
    @Column(name = "MOBILE_PHONE", unique = false, nullable = true, insertable = true, updatable = true, length = 16)
	private String mobilePhone;
	/** ADDRESS - 地址 */
	@Length(max = 65535, message = "地址长度不能超过65535个字符")
    @Column(name = "ADDRESS", unique = false, nullable = true, insertable = true, updatable = true, length = 65535)
	private String address;
	/** LOGIN_ID - 登录账户 */
	@NotBlank(message = "登录账户不能为空")
	@Length(max = 32, message = "登录账户长度不能超过32个字符")
    @Column(name = "LOGIN_ID", unique = false, nullable = false, insertable = true, updatable = true, length = 32)
	private String loginId;
	/** PASSWORD - 密码 */
	@NotBlank(message = "密码不能为空")
	@Length(max = 32, message = "密码长度不能超过32个字符")
    @Column(name = "PASSWORD", unique = false, nullable = false, insertable = true, updatable = true, length = 32)
	private String password;
	/** SALT - 盐 */
	@NotBlank(message = "盐不能为空")
	@Length(max = 32, message = "盐长度不能超过32个字符")
    @Column(name = "SALT", unique = false, nullable = false, insertable = true, updatable = true, length = 32)
	private String salt;
	/** VERSION - 版本 */
	@NotNull(message = "版本不能为空")
    @Column(name = "VERSION", unique = false, nullable = false, insertable = true, updatable = true, length = 19)
	private Long version;

	public SysUser(){
	}

	public SysUser(
		Long id
	){
		this.id = id;
	}


	public void setId(Long value) {
		this.id = value;
	}

	public Long getId() {
		return this.id;
	}

	public void setUserName(String value) {
		this.userName = value;
	}

	public String getUserName() {
		return this.userName;
	}

	public void setSex(String value) {
		this.sex = value;
	}

	public String getSex() {
		return this.sex;
	}

	public void setAge(Integer value) {
		this.age = value;
	}

	public Integer getAge() {
		return this.age;
	}

	public void setMobilePhone(String value) {
		this.mobilePhone = value;
	}

	public String getMobilePhone() {
		return this.mobilePhone;
	}

	public void setAddress(String value) {
		this.address = value;
	}

	public String getAddress() {
		return this.address;
	}

	public void setLoginId(String value) {
		this.loginId = value;
	}

	public String getLoginId() {
		return this.loginId;
	}

	public void setPassword(String value) {
		this.password = value;
	}

	public String getPassword() {
		return this.password;
	}

	public void setSalt(String value) {
		this.salt = value;
	}

	public String getSalt() {
		return this.salt;
	}

	public void setVersion(Long value) {
		this.version = value;
	}

	public Long getVersion() {
		return this.version;
	}

	@Override
	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("ID",getId())
			.append("USER_NAME",getUserName())
			.append("SEX",getSex())
			.append("AGE",getAge())
			.append("MOBILE_PHONE",getMobilePhone())
			.append("ADDRESS",getAddress())
			.append("LOGIN_ID",getLoginId())
			.append("PASSWORD",getPassword())
			.append("SALT",getSalt())
			.append("VERSION",getVersion())
			.toString();
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getId())
			.toHashCode();
	}

	@Override
	public boolean equals(Object obj) {
		if(this.getId() == null){
			return false;
		}
		if(!(obj instanceof SysUser)){
			return false;
		}
		if(this == obj) {
			return true;
		}
		SysUser other = (SysUser)obj;
		return new EqualsBuilder()
			.append(getId(),other.getId())
			.isEquals();
	}
}